﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Iprojects.Data;
namespace Iprojects.Report
{
    public class FamilyPhoneBook:FamilyPerson
    {


        public FamilyPhoneBook(long FamiyID)
        {
            using (ZakahEntities db = new ZakahEntities())
            {
                FamilyPerson currentFamilyPerson = db.FamilyPersons.FirstOrDefault(x => x.id == FamiyID);
                this.Husbandid = currentFamilyPerson.Husbandid;
                this.wifeid = currentFamilyPerson.wifeid;
                this.ChildBelow18 = currentFamilyPerson.childnumunder18;
                this.ChildNumup18 = currentFamilyPerson.childNumabove18;
                this.FamilyIncom = currentFamilyPerson.Income;
                this.street = currentFamilyPerson.street;
                this.HomeNumber = currentFamilyPerson.HomeNumber;
                this.Telephone = currentFamilyPerson.Telephone;
                this.cellnumber = currentFamilyPerson.cellnumber;
           
               
                Person husbbund = db.Persons.FirstOrDefault(x => x.IDnum == this.Husbandid);
                if (null != husbbund)
                {
                    this.HusbundFullName = husbbund.FirstName + " " + husbbund.FatherName + " " + husbbund.LastName + " #" + husbbund.IDnum;
                    this.FamilyName = husbbund.LastName;
                    
                }
                husbbund = db.Persons.FirstOrDefault(x => x.IDnum == this.wifeid);
                if (null != husbbund)
                {
                    this.WifeFullName = husbbund.FirstName + " " + husbbund.FatherName + " " + husbbund.LastName + " #" + husbbund.IDnum;
                    if (string.IsNullOrEmpty(this.FamilyName))
                    {
                        this.FamilyName = husbbund.LastName;
                    }
                  
                }
            }

        
        
        }

        public string  HusbundFullName
        {
            get;
            set;
        }
        public string WifeFullName
        {
            get;
            set;
        }
        public long  ChildNumup18
        {
            get;
            set;
        }
        public long ChildBelow18
        {
            get;
            set;
        }
       
        public long? FamilyIncom
        {
            get;
            set;
        }
        public string date
        {
            get;
           
            set;
        }

        public string AdditionalData
        {
            get;

            set;
        }
        public long?  Amount
        {
            get;
            set;
        }
        public string  Titleamount
        {
            get;
            set;
        }

        public string ProjectName
        {
            get;
            set;
        }
        public string FamilyName
        {
            get;
            set;
        }
       
        
    }
}
